﻿namespace JxcLite.Repositories;

class ReportRepository
{
    internal static Task<PagingResult<BillDetailInfo>> QueryBillDetailsAsync(Database db, PagingCriteria criteria)
    {
        var sql = @"
select a.Id,a.CreateTime,a.SeqNo,a.Code,a.Name,a.Category,a.Model,a.Producer,a.Unit,a.Qty,a.Price,a.Amount,a.Note as ListNote
      ,b.Type,b.BillNo,b.Status,b.BillDate,b.Partner,b.ContractNo,b.InvoiceNo,b.SettleMode,b.TotalAmount
      ,b.Logistics,b.LogisticsNo,b.LogisticsFee,b.ReturnNo,b.Note 
from JxBillList a 
left join JxBillHead b on b.Id=a.HeadId 
where a.CompNo=@CompNo";
        return db.QueryPageAsync<BillDetailInfo>(sql, criteria);
    }

    internal static Task<PagingResult<ProfitInfo>> QueryProfitsAsync(Database db, PagingCriteria criteria)
    {
        var sql = @"select a.* 
     ,0 as ImportAmount
     ,0 as ImportReturnAmount
     ,0 as ExportAmount
     ,0 as ExportReturnAmount
     ,0 as Profit
from JxGoods a 
where a.CompNo=@CompNo";
        return db.QueryPageAsync<ProfitInfo>(sql, criteria);
    }
}